<?php

/**
 * @version     1.0.0
 * @package     com_general
 * @copyright   Copyright (C) 2013. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 * @author      kent <kent@viseed.com> - http://viseed.com
 */
// No direct access
defined('_JEXEC') or die;

/**
 * @param	array	A named array
 * @return	array
 */
function GeneralBuildRoute(&$query) {
  $segments = array();
  if (isset($query['task'])) {
    $segments[] = implode('/', explode('.', $query['task']));
    unset($query['task']);
  }
  if(isset($query['view']))
       {
                $segments[] = $query['view'];
                unset( $query['view'] );
       }   
  if (isset($query['id'])) {
   
    $segments[] = $query['id'];
    unset($query['id']);
  } 
  return $segments;
}

/**
 * @param	array	A named array
 * @param	array
 *
 * Formats:
 *
 * index.php?/general/task/id/Itemid
 *
 * index.php?/general/id/Itemid
 */
function GeneralParseRoute($segments) {
  $vars = array();

//   view is always the first element of the array
//	$count = count($segments);
//    
//    if ($count)
//	{
//		$count--;
//		$segment = array_pop($segments) ;
//		if (is_numeric($segment)) {
//			$vars['id'] = $segment;
//		}
//        else{
//            $count--;
//            $vars['task'] = array_pop($segments) . '.' . $segment;
//        }
//	}
//
//	if ($count)
//	{   
//        $vars['task'] = implode('.',$segments);
//	}    
  switch ($segments[0]) {
    case 'about':
      $vars['view'] = 'about';
      $id = $segments[1];
      //    print_r($query);//    print_r($query);
                     //  $vars['id'] = (int) $id[0];
      $vars['id'] = $id;
      break;
  }  
  return $vars;
}
